package com.isunland.managesystem.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.CustomerContact;
import java.util.List;

public class CustomerContactAdapter extends ArrayAdapter<CustomerContact> {

  /**
   * ViewHolder class for layout.<br />
   * <br />
   * Auto-created on 2015-07-01 20:49:15 by Android Layout Finder
   * (http://www.buzzingandroid.com/tools/android-layout-finder)
   */
  private static class ViewHolder {
    public final LinearLayout rootView;
    public final TextView tvProductCustomerContactList;
    public final TextView tvCustomerStatusCustomerContactList;
    public final TextView tvTimeItemAttendanceList;

    private ViewHolder(LinearLayout rootView, TextView tvProductCustomerContactList,
        TextView tvCustomerStatusCustomerContactList, TextView tvTimeItemAttendanceList) {
      this.rootView = rootView;
      this.tvProductCustomerContactList = tvProductCustomerContactList;
      this.tvCustomerStatusCustomerContactList = tvCustomerStatusCustomerContactList;
      this.tvTimeItemAttendanceList = tvTimeItemAttendanceList;
    }

    public static ViewHolder create(LinearLayout rootView) {
      TextView tvProductCustomerContactList =
          (TextView) rootView.findViewById(R.id.tv_product_customerContactList);
      TextView tvCustomerStatusCustomerContactList =
          (TextView) rootView.findViewById(R.id.tv_customerStatus_customerContactList);
      TextView tvTimeItemAttendanceList =
          (TextView) rootView.findViewById(R.id.tv_time_ItemAttendanceList);
      return new ViewHolder(rootView, tvProductCustomerContactList,
          tvCustomerStatusCustomerContactList, tvTimeItemAttendanceList);
    }
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.adapter_customer_contact_list, parent, false);
      vh = ViewHolder.create((LinearLayout) view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }
    CustomerContact item = getItem(position);

    vh.tvProductCustomerContactList.setText(item.getCommDesc());
    vh.tvCustomerStatusCustomerContactList.setText(item.getCustomerStatusText());
    vh.tvTimeItemAttendanceList.setText(item.getContactModeText());

    return vh.rootView;
  }

  private LayoutInflater mInflater;

  // Constructors
  public CustomerContactAdapter(Context context, List<CustomerContact> objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }

  public CustomerContactAdapter(Context context, CustomerContact[] objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }
}
